from pyorthanc import find, Orthanc
import numpy as np
import os
from tifffile import imsave
orthanc = Orthanc('http://localhost:8042',
                  username='orthanc', password='orthanc')

def get_dicom_from_Orthanc(modality='MR'):
    patients = find(
        orthanc=orthanc,
        # Optional: filter with pyorthanc.Series object
        series_filter=lambda s: s.modality == modality
    )
    for patient in patients:
        # patient.get_zip()  # DICOM files' content in bytes
          print(patient.name)  
          for study in patient.studies:
                  print(study.id_)
                  # for series in study.series: # 此处有三个模态
                  #     for instance in series.instances:
                         
                #  根据tag获取内容
                #  print(instance.get_content_by_tag('Modality'))
                #  # Or
                #  print(instance.get_content_by_tag('0008-0060'))
if __name__ == '__main__':
    patient_id='PN0002735-DONG_XIU_MEI'
    study_id='5dd0ea50bee7ca0001fe531f'
    get_dicom_from_Orthanc()
